<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>商品管理</title>
    <link href="https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.css" rel="stylesheet"/>
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
    <link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@500&display=swap" rel="stylesheet" />
    <style>
        body {
            background: #f8f1f4;
            font-family: 'Orbitron', sans-serif;
            color: #8a4a6c;
            margin: 0;
            padding: 0;
        }
        .container {
            width: 95%;
            margin: 40px auto;
        }
        .navbar {
            background-color: #fff0f5;
            padding: 15px 30px;
            display: flex;
            justify-content: center;
            gap: 30px;
            box-shadow: 0 0 10px #ff6b9d;
        }
        .navbar a {
            color: #ff6b9d;
            text-decoration: none;
            font-size: 16px;
            letter-spacing: 1px;
        }
        .navbar a:hover {
            text-shadow: 0 0 10px #ff6b9d;
        }
        h2 {
            text-align: center;
            color: #ff6b9d;
            text-shadow: 0 0 5px #ff6b9d;
            margin-bottom: 20px;
        }
        .add-btn {
            display: inline-block;
            padding: 10px 20px;
            background: transparent;
            border: 2px solid #ff6b9d;
            color: #ff6b9d;
            border-radius: 6px;
            margin-bottom: 20px;
            text-decoration: none;
            transition: all 0.3s ease;
        }
        .add-btn:hover {
            background: #ff6b9d;
            color: #fff;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            background: #fff5f8;
            box-shadow: 0 0 15px #ff6b9d;
        }
        th, td {
            padding: 12px;
            border: 1px solid #ff6b9d;
            text-align: center;
            vertical-align: middle;
        }
        th {
            background-color: #ffe6ee;
            color: #ff6b9d;
        }
        tr:hover {
            background-color: #fff0f5;
        }
        a.action-link {
            color: #ff6b9d;
            text-decoration: none;
            margin: 0 5px;
        }
        a.action-link:hover {
            text-shadow: 0 0 5px #ff6b9d;
        }
    </style>
</head>
<body>
<div class="navbar">
    <a href="${pageContext.request.contextPath}/goods/list">🧸 商品管理</a>
    <a href="${pageContext.request.contextPath}/category/list">📁 分类管理</a>
    <a href="${pageContext.request.contextPath}/order/list">📦 订单管理</a>
    <a href="${pageContext.request.contextPath}/user/list">👤 用户管理</a>
    <a href="${pageContext.request.contextPath}/user/logout">🚪 退出登录</a>
</div>

<div class="container">
    <h2>商品管理</h2>
    <a href="${pageContext.request.contextPath}/goods/addForm" class="add-btn">➕ 添加新商品</a>
    <table>
        <tr>
            <th>商品ID</th>
            <th>名称</th>
            <th>介绍</th>
            <th>价格</th>
            <th>库存</th>
            <th>分类ID</th>
            <th>操作</th>
        </tr>
        <c:forEach var="goods" items="${goodsList}">
            <tr>
                <td>${goods.gid}</td>
                <td>${goods.name}</td>
                <td>${goods.intro}</td>
                <td>${goods.price}</td>
                <td>${goods.stock}</td>
                <td>${goods.categoryId}</td>
                <td>
                    <a href="${pageContext.request.contextPath}/goods/editForm/${goods.gid}" class="action-link">编辑</a> |
                    <a href="${pageContext.request.contextPath}/goods/delete/${goods.gid}" class="action-link"
                       onclick="return confirm('确定删除该商品吗？');">删除</a>
                </td>
            </tr>
        </c:forEach>
    </table>
</div>
</body>
</html>